/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.gianluca.lotteria.entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author eginfer
 */
@Entity
@Table(name = "persone")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Persone.findAll", query = "SELECT p FROM Persone p"),
    @NamedQuery(name = "Persone.findById", query = "SELECT p FROM Persone p WHERE p.id = :id"),
    @NamedQuery(name = "Persone.findByNome", query = "SELECT p FROM Persone p WHERE p.nome = :nome"),
    @NamedQuery(name = "Persone.findByCognome", query = "SELECT p FROM Persone p WHERE p.cognome = :cognome")})
public class Persone implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID")
    private Integer id;
    @Column(name = "Nome")
    private String nome;
    @Column(name = "Cognome")
    private String cognome;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "iDPersona")
    private Collection<Blocchetti> blocchettiCollection;

    public Persone() {
    }

    public Persone(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }

    public String getCognome() {
        return cognome;
    }

    public void setCognome(String cognome) {
        this.cognome = cognome;
    }

    @XmlTransient
    public Collection<Blocchetti> getBlocchettiCollection() {
        return blocchettiCollection;
    }

    public void setBlocchettiCollection(Collection<Blocchetti> blocchettiCollection) {
        this.blocchettiCollection = blocchettiCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Persone)) {
            return false;
        }
        Persone other = (Persone) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.gianluca.lotteria.entities.Persone[ id=" + id + " ]";
    }
    
}
